var M = new Array(
  "a",
  "b",
  "c",
  "d",
  "e",
  "f",
  "g",
  "h",
  "i",
  "j",
  "k",
  "l",
  "m",
  "n",
  "o",
  "p",
  "q",
  "r",
  "s",
  "t",
  "u",
  "v",
  "w",
  "x",
  "y",
  "z"
);

function cC(c0, c2) {
  var cZ = [];
  for (var cY = 0; cY < c0.length; cY++) {
    var c3 = [];
    var cX = c0[cY].split("|");
    c3.secretStr = cX[0];
    c3.buttonTextInfo = cX[1];
    var c1 = [];
    c1.train_no = cX[2];
    c1.station_train_code = cX[3];
    c1.start_station_telecode = cX[4];
    c1.end_station_telecode = cX[5];
    c1.from_station_telecode = cX[6];
    c1.to_station_telecode = cX[7];
    c1.start_time = cX[8];
    c1.arrive_time = cX[9];
    c1.lishi = cX[10];
    c1.canWebBuy = cX[11];
    c1.yp_info = cX[12];
    c1.start_train_date = cX[13];
    c1.train_seat_feature = cX[14];
    c1.location_code = cX[15];
    c1.from_station_no = cX[16];
    c1.to_station_no = cX[17];
    c1.is_support_card = cX[18];
    c1.controlled_train_flag = cX[19];
    c1.gg_num = cX[20] ? cX[20] : "--";
    c1.gr_num = cX[21] ? cX[21] : "--";
    c1.qt_num = cX[22] ? cX[22] : "--";
    c1.rw_num = cX[23] ? cX[23] : "--";
    c1.rz_num = cX[24] ? cX[24] : "--";
    c1.tz_num = cX[25] ? cX[25] : "--";
    c1.wz_num = cX[26] ? cX[26] : "--";
    c1.yb_num = cX[27] ? cX[27] : "--";
    c1.yw_num = cX[28] ? cX[28] : "--";
    c1.yz_num = cX[29] ? cX[29] : "--";
    c1.ze_num = cX[30] ? cX[30] : "--";
    c1.zy_num = cX[31] ? cX[31] : "--";
    c1.swz_num = cX[32] ? cX[32] : "--";
    c1.srrb_num = cX[33] ? cX[33] : "--";
    c1.yp_ex = cX[34];
    c1.seat_types = cX[35];
    c1.exchange_train_flag = cX[36];
    c1.houbu_train_flag = cX[37];
    c1.houbu_seat_limit = cX[38];
    c1.yp_info_new = cX[39];
    c1.dw_flag = cX[46];
    c1.stopcheckTime = cX[48];
    c1.country_flag = cX[49];
    c1.local_arrive_time = cX[50];
    c1.local_start_time = cX[51];
    c1.from_station_name = c2[cX[6]];
    c1.to_station_name = c2[cX[7]];
    c3.queryLeftNewDTO = c1;
    cZ.push(c3);
  }
  return cZ;
}

function decryptStationNames(station_names) {
  let c = [];
  let y = [];
  for (let ai = 0; ai < 26; ai++) {
    c[ai] = [];
  }
  let B = [];
  let Y = "";
  let Z = [];
  for (var ad = 0; ad < 5; ad++) {
    Z[ad] = [];
  }
  let U;

  if (typeof station_names == "undefined") {
    return undefined;
  }

  var an = station_names.split("@");
  for (var al = 0; al < an.length; al++) {
    var ap = an[al];
    var aq = ap.toString().charAt(0);
    for (var ak in M) {
      if (aq == M[ak]) {
        var ao = ap.split("|");
        if (ao[8] == "" && ao[9] == "") {
          c[ak].push(ap.split("|"));
        }
      }
    }
    if (ap.length > 0) {
      ap = ap.split("|");
      if (Y != "" && ap[2] == Y) {
        favcity = ap;
        B.unshift(ap);
        if (al > 6) {
          B.push(ap);
        }
      } else {
        if (ap[8] != "" && ap[9] != "") {
          y.push(ap);
        } else {
          B.push(ap);
        }
      }
    }
  }
  g = c[0].concat(c[1]).concat(c[2]).concat(c[3]).concat(c[4]);
  e = c[5].concat(c[6]).concat(c[7]).concat(c[8]).concat(c[9]);
  d = c[10].concat(c[11]).concat(c[12]).concat(c[13]).concat(c[14]);
  b = c[15].concat(c[16]).concat(c[17]).concat(c[18]).concat(c[19]);
  ag = c[20]
    .concat(c[21])
    .concat(c[22])
    .concat(c[23])
    .concat(c[24])
    .concat(c[25]);
  Z[0] = [c[0], c[1], c[2], c[3], c[4]];
  Z[1] = [c[5], c[6], c[7], c[8], c[9]];
  Z[2] = [c[10], c[11], c[12], c[13], c[14]];
  Z[3] = [c[15], c[16], c[17], c[18], c[19]];
  Z[4] = [c[20], c[22], c[23], c[24], c[25]];
  U = B.concat(y);
  for (var al = 0; al < U.length; al++) {
    U[al].push(al);
  }
  return B;
}

module.exports = {
  cC,
  decryptStationNames,
};
